1 (Liquid Crystal Display) תצוגת LCD בפרויקט ישנה אפשרות לראות את כל הנתונים על גבי תצוגת ה- LCD באופן ברור ונוח. תצוגה זו היא בעלת 2 שורות של מידע בעלות 16 תווים כל אחת. המשתמש יכול לראות על גבי ה- LCD בכל זמן משתנים ואירועים הקורים במהלך פעולת המערכת. חיבור התצוגה לבקר
2 פירוט הדקי הרכיב VSS אדמה של הרכיב. 5V. אספקת המתח לרכיב, מחוברת ל- VCC - VL קובע את עוצמת ההארה של ה- LCD, אם נחבר רגל זו לאדמה העוצמה תהיה מכסימלית. - RS הדק הקובע אם המידע לפורט המידע של ה- LCD יהיה בקרה או נתונים, כאשר ההדק ב- 1 לוגי, מילת המידע המגיעה בקוד אסקי תוצג במסך וכאשר ההדק ב- 0 לוגי, מילת המידע תהווה מילת בקרה שתקבע למשל מיקום הסמן, ניקוי מסך, כוון הכתיבה ועוד. - R/W זוהי רגל בחירה בין כתיבה לקריאה. אם הדק זה נמצא ברמה לוגית של "0" מתאפשרת כתיבה לרכיב. ואם הדק זה נמצא ברמה לוגית של "1" מתאפשרת קריאה מה- RAM של הרכיב. אם נחבר ההדק זה לאדמה תתבצע רק כתיבה לתצוגה. - E הדק זה מאפשר כתיבה או קריאה. קריאה או כתיבה מתבצעת כאשר בהדק יש דרבון שלילי (ירידת שעון), לכן בתוכנה אנו דואגים להעלות את ההדק ל- 1 לוגי ולהורידה שוב ל- 0 לוגי. אלו הם קווי המידע דו כוונים של הרכיב, כאשר,RS=0 - D7 D0 הם ישמשו כקווי בקרה וכאשר,RS=1 הם ישמשו כקווי נתונים. הפונקציות להפעלת ה- LCD lcd_config(); אתחול // LCD הצבת סמן בשורה 1 במיקום // 10 lcd_line(1,10); lcd_string("abcd1234"); cursor(0); cursor(1); הצגת מחרוזת במסך // //cursor off //cursor on נקה מסך // lcd_clr(); הצג תו // lcd_display( x );
3 טבלת פעולה של ה- LCD Code Instruction RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Description Clear display 0 0 0 0 0 0 0 0 0 1 Clears display and returns cursor to the home position (address 0). Cursor home 0 0 0 0 0 0 0 0 1 * Returns cursor to home position (address 0). Also returns display being shifted to the original position. DDRAM contents remains unchanged. Entry mode set 0 0 0 0 0 0 0 1 I/D S Sets cursor move direction (I/D), specifies to shift the display (S). These operations are performed during data read/write. Display On/Off 0 0 0 0 0 0 1 D C B Sets On/Off of all display (D), cursor On/Off control (C) and blink of cursor position character (B). Cursor/display 0 0 0 0 0 1 S/C R/L * * Sets cursor-move or display-shift (S/C), shift shift direction (R/L). DDRAM contents remains unchanged. Function set 0 0 0 0 1 DL N F * * Sets interface data length (DL), number of display line (N) and character font(f). Set CGRAM address 0 0 0 1 CGRAM address Sets the CGRAM address. CGRAM data is sent and received after this setting. Set DDRAM address Read busy-flag and address counter Write to CGRAM or DDRAM Read from CGRAM or DDRAM 0 0 1 DDRAM address Sets the DDRAM address. DDRAM data is sent and received after this setting. 0 1 BF CGRAM / DDRAM address Reads Busy-flag (BF) indicating internal operation is being performed and reads CGRAM or DDRAM address counter contents (depending on previous instruction). 1 0 write data Writes data to CGRAM or DDRAM. 1 1 read data Reads data from CGRAM or DDRAM. Remarks: - DDRAM = Display Data RAM. - CGRAM = Character Generator RAM. - DDRAM address corresponds to cursor position. - * = Don't care.. Bit name Setting / Status I/D 0 = Decrement cursor position 1 = Increment cursor position S 0 = No display shift 1 = Display shift D 0 = Display off 1 = Display on C 0 = Cursor off 1 = Cursor on B 0 = Cursor blink off 1 = Cursor blink on S/C 0 = Move cursor 1 = Shift display R/L 0 = Shift left 1 = Shift right DL 0 = 4-bit interface 1 = 8-bit interface N 0 = 1/8 or 1/11 Duty (1 line) 1 = 1/16 Duty (2 lines) F 0 = 5x7 dots 1 = 5x10 dots BF 0 = Can accept instruction 1 = Internal operation in progress
4 פונקציות ה- LCD הפונקציות ל- LCD נכתבו על פי הטבלה המצורפת הנ"ל : פונקצית אתחול ל- LCD //=======================CONFIG THE LCD======================= void lcd_config() send_command(0x38); send_command(0x0e); send_command(0x01); send_command(0x06); //Initialization of The LCD //8bit,2 line,5*7 dot //display on,cursor on,cursor blink //clear_display // increment cursor,no display shift פונקצית הצבת סמן //===========================LCD LINE NUMBER==================== void lcd_line(char line_number,char p) switch(line_number) case 1: send_command(0x80+p); break; case 2: send_command(0xc0+p); break; הסבר מילת הבקרה להצבת סמן במיקום מסוים ב- LCD תלויה בערך שנשלח לזיכרון DDRAM הפנימי של ה-. LCD חלק מהכתובות מייצגות את השורות. שורה ראשונה: 0x00-0x0F שורה שנייה: 0x40-0x4F בתוספת ביט 7 שב- 1 לוגי, לכן נקבל ערך 0x80 להתחלת שורה ראשונה ו- 0xc0 להתחלת שורה שנייה.
5 פונקצית שליחת מחרוזת ל- LCD void lcd_string(char str[]) int i=0; while(str[i]) send_data(str[i++]); הפונקציה שולחת תו אחרי תו בלולאה ל- LCD עד לזיהוי (0) null בסוף כל מחרוזת. send_command(unsigned char command) RS=0; PORT_LCD=command; E=1; send_data(char data_to_lcd) RS=1; PORT_LCD=data_to_lcd; E=1; פונקציות שליחת מידע או מילת בקרה ל- LCD הפונקציה הראשונה שולחת מילת בקרה ל- (RS=0) LCD דרך - P0 (PORT_LCD) ומחוללת פולס בהדק -E. הפונקציה השנייה שולחת מילת נתונים ל- (RS=1) LCD באותה צורה.